//
//  HRCollectionViewModel.m
//  Hear
//
//  Created by mac on 2017/6/14.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRCollectionViewModel.h"
#import "HRMineButtonCell.h"
#import "HRFollowDynamicViewController.h"
#import "HRSettingViewController.h"
#import "HRNoviceBootViewController.h"
#import "HRDynamicViewController.h"
#import "HRFeedBackViewController.h"
#import "HRRecommendFriendsViewController.h"
#import "HRFollowRootViewController.h"
#import "HRExtractMoneyViewController.h"
#import "HRSignViewController.h"

@interface HRCollectionViewModel ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic, strong)UICollectionView *collectionView;

@end
@implementation HRCollectionViewModel

-(void)setUserInfoModel:(HRUpdataUserInfoModel *)userInfoModel{
    _userInfoModel = userInfoModel;
}


-(void)setContentArray:(NSMutableArray *)contentArray{
    _contentArray = contentArray;
    [self.collectionView reloadData];
}

-(void)handleWithCollection:(UICollectionView *)collectionView{
    self.collectionView = collectionView;
    collectionView.delegate  =self;
    collectionView.dataSource = self;
}

#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.contentArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HRMineButtonCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HRMineButtonCell" forIndexPath:indexPath];
    
    WeakSelf
    cell.clickindexBlock = ^(){
        [weakSelf clickIndexPath:indexPath.row];
    };
    return cell;

}



- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
    
    [(HRMineButtonCell *)cell configureCellWithContent:self.contentArray[indexPath.row]];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (self.scrollViewDidScrollBlock){
        self.scrollViewDidScrollBlock(scrollView.contentOffset.y);
    }
}
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
}

- (void)clickIndexPath:(NSUInteger)index{
    switch (index) {
        case 0:
        {
            [MobClick event:@"Hearer8"];
            HRDynamicViewController *dynamicVC = [HRDynamicViewController new];
            
            dynamicVC.currentUserID = USERID;
            [VIEWCCONTROLER.navigationController pushViewController:dynamicVC animated:YES];
        }
            break;
        case 1:
        {
            if ([_userInfoModel.IsShowCash intValue]){
                HRSignViewController *VC = [HRSignViewController new];
                VC.userInfoModel = self.userInfoModel;
                [VIEWCCONTROLER.navigationController pushViewController:VC animated:YES];
            }else{
                HRSettingViewController *settingVC = [HRSettingViewController new];
                [VIEWCCONTROLER.navigationController pushViewController:settingVC animated:YES];
            }
            
            
        }
            break;
        case 2:
        {
            if ([_userInfoModel.IsShowCash intValue]){
                HRExtractMoneyViewController *monetVC = [[HRExtractMoneyViewController alloc] initWithNibName:@"HRExtractMoneyViewController" bundle:nil];
                monetVC.userInfoModel = self.userInfoModel;
                [VIEWCCONTROLER.navigationController pushViewController:monetVC animated:YES];
            }else{
                HRNoviceBootViewController *rootVC = [HRNoviceBootViewController new];
                rootVC.title = @"新手引导";
                rootVC.requestUrl = NoviecUrl;
                [VIEWCCONTROLER.navigationController pushViewController:rootVC animated:YES];
            }
            
        }
            break;
        case 3:
        {
            if ([_userInfoModel.IsShowCash intValue]){
                HRSettingViewController *settingVC = [HRSettingViewController new];
                [VIEWCCONTROLER.navigationController pushViewController:settingVC animated:YES];
            }else{
                HRFeedBackViewController *feedVC = [HRFeedBackViewController new];
                [VIEWCCONTROLER.navigationController pushViewController:feedVC animated:YES];
            }
            
            
        }
            break;
        case 4:
        {
            if ([_userInfoModel.IsShowCash intValue]){
                HRNoviceBootViewController *rootVC = [HRNoviceBootViewController new];
                rootVC.title = @"新手引导";
                rootVC.requestUrl = NoviecUrl;
                [VIEWCCONTROLER.navigationController pushViewController:rootVC animated:YES];
            }else{
                HRFeedBackViewController *feedVC = [HRFeedBackViewController new];
                [VIEWCCONTROLER.navigationController pushViewController:feedVC animated:YES];
            }
            
            
        }
            break;
        case 5:
        {
            if ([_userInfoModel.IsShowCash intValue]){
                HRFeedBackViewController *feedVC = [HRFeedBackViewController new];
                [VIEWCCONTROLER.navigationController pushViewController:feedVC animated:YES];

            }
            
        }
            break;
        default:
            break;
    }
}


@end
